package com.ycl.productservice.client;

import com.ycl.productservice.entity.Order;
import com.ycl.productservice.entity.PageVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient(value = "order-service")
public interface OrderFeignClient {

    /**
     * 需要调用的商品接口
     * @param id
     * @return
     */
    @GetMapping("/order/{id}")
    ResponseEntity<Order> findOrderById(@PathVariable Integer id);

    @GetMapping("/orders")
    ResponseEntity<List<Order>> findAllOrders();

    @GetMapping("/orders-page")
    ResponseEntity<PageVO> findOrdersPage(
            @RequestParam(value = "current",required = false,defaultValue = "1") Integer current,
            @RequestParam(value = "pageSize",required = false,defaultValue = "10") Integer pageSize);

    @PostMapping("/order")
    ResponseEntity<String> addOrder(@RequestBody Order order);

    @PutMapping("/order")
    ResponseEntity<String> updateOrder(@RequestBody Order order);

    @DeleteMapping("/order/{id}")
    ResponseEntity<String> deleteOrder(@PathVariable Integer id);
}
